import { updateAuthCode } from '@/services/OpenService'
import { Button, Result } from 'antd'
import { useEffect } from 'react'
import { useSearchParam } from 'react-use'

const AuthResult = () => {
  let authCode = useSearchParam('auth_code')
  useEffect(() => {
    if (authCode) updateAuthCode({ code: authCode }).then()
  }, [authCode])
  return (
    <div>
      <Result
        status="success"
        title="公众号授权成功"
        extra={[
          <Button type="primary" key="console" href="/admin/mp/info">
            返回
          </Button>,
        ]}
      />
    </div>
  )
}

export default AuthResult
